/* ---------------------------------------------------------------------------------------------------------------------
 * File: mainwindow.cpp
 * Author: Joe Huang, Daniel Pop
 * Purpose: The main purpose for ths class is to be the main window and to transition between screens,
 *  and to direct the user to select three choices of Playing, Creating, Editing.
 *  Daniel: I constructed this screen to be simple and to figure out how to transition from one screen to the next,
 *  using signals and slots, Joe discovered a simpler/cleaner way to do this and we decided to use his method.
 * ---------------------------------------------------------------------------------------------------------------------*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "scorekeeperscreen.h"
#include "testing.h"
#include "createscreen.h"
#include <QCoreApplication>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //testingWindow = new testing();
    viewEditWindow = new ViewEditScreen();
    createWindow = new CreateScreen();
}

MainWindow::~MainWindow()
{
    delete ui;
}

//Links to the testing screen, removed from the final product
/*
void MainWindow::showTestingScreen()
{
    testingWindow->show();
}
*/

//This is the screen that pops up if the player clicks on the play button
void MainWindow::showScoreScreen()
{
    scoreKeeperWindow = new PickTeams();
    scoreKeeperWindow->show();
}

//This is the screen that pops up if the player clicks on the view/edit button
void MainWindow::showViewEditScreen()
{
    viewEditWindow->show();
}

//This is the screen that pops up if the player clicks on the create button
void MainWindow::showCreateScreen()
{
    createWindow->show();
}

//This is qt generated code
void MainWindow::setOrientation(ScreenOrientation orientation)
{
    Qt::WidgetAttribute attribute;
    switch (orientation) {
#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
    case ScreenOrientationLockPortrait:
        attribute = static_cast<Qt::WidgetAttribute>(128);
        break;
    case ScreenOrientationLockLandscape:
        attribute = static_cast<Qt::WidgetAttribute>(129);
        break;
    default:
    case ScreenOrientationAuto:
        attribute = static_cast<Qt::WidgetAttribute>(130);
        break;
#else // QT_VERSION < 0x040702
    case ScreenOrientationLockPortrait:
        attribute = Qt::WA_LockPortraitOrientation;
        break;
    case ScreenOrientationLockLandscape:
        attribute = Qt::WA_LockLandscapeOrientation;
        break;
    default:
    case ScreenOrientationAuto:
        attribute = Qt::WA_AutoOrientation;
        break;
#endif // QT_VERSION < 0x040702
    };
    setAttribute(attribute, true);
}

void MainWindow::showExpanded()
{
#if defined(Q_WS_SIMULATOR)
    showFullScreen();
#elif defined(Q_WS_MAEMO_5)
    showMaximized();
#else
    show();
#endif
}

